#include "log.h"

int init_log(const std::string& path,
						 const std::string& file,
						 const int	flag_print_file,
						 const int	flag_print_screen,
						 const int  flag_log_level,
						 const std::vector<std::string>& modules,
						 const int  max_line,
						 const int  maz_size)
{
	singleton<Log>::Instance().set_path(path.c_str());
	singleton<Log>::Instance().set_filename(file.c_str());
	singleton<Log>::Instance().set_maxline(max_line);
	singleton<Log>::Instance().set_maxsize(maz_size);
	if(flag_print_file)	singleton<Log>::Instance().enable_print_file(true);	
	if(flag_print_screen)	singleton<Log>::Instance().enable_print_screen(true);
	if( flag_log_level >=1 ) singleton<Log>::Instance().enable_log_level(LOG_FLAG(LF_FATAL), true);
	if( flag_log_level >=2 ) singleton<Log>::Instance().enable_log_level(LOG_FLAG(LF_ERROR), true);
	if( flag_log_level >=3 ) singleton<Log>::Instance().enable_log_level(LOG_FLAG(LF_WARN), true);
	if( flag_log_level >=4 ) singleton<Log>::Instance().enable_log_level(LOG_FLAG(LF_INFO), true);
	if( flag_log_level >=5 ) singleton<Log>::Instance().enable_log_level(LOG_FLAG(LF_TRACE), true);
	if( flag_log_level >=6 ) singleton<Log>::Instance().enable_log_level(LOG_FLAG(LF_DEBUG), true);	
	for(std::size_t i=0 ; i<modules.size() ; i++ )
	{
		singleton<Log>::Instance().enable_log_module(modules[i].c_str(), true);
	}
	return singleton<Log>::Instance().open();
}
